package com.x.client.adapter

import android.support.v4.content.ContextCompat
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.x.client.R
import com.x.client.bean.ColorBean

/**
 * Creator : GG
 * Date    : 2018/6/15
 * Mail    : gg.jin.yu@gmai.com
 * Explain :
 */
class ColorAdapter(data: List<ColorBean> = listOf()) : BaseQuickAdapter<ColorBean, BaseViewHolder>(R.layout.item_color, data) {
    override fun convert(helper: BaseViewHolder, item: ColorBean) {

        val colorTextView = helper.getView<TextView>(R.id.color)

        colorTextView.text = item.colorName
        val d = ContextCompat.getDrawable(mContext, item.colorRes)
        d?.setBounds(0, 0, d.minimumWidth, d.minimumHeight)
        colorTextView.setCompoundDrawables(null, d, null, null)

        if (item.status) {
            colorTextView.setTextColor(ContextCompat.getColor(mContext, R.color.text_orange))
        } else {
            colorTextView.setTextColor(ContextCompat.getColor(mContext, R.color.text_black))
        }
    }
}